<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<script src="<c:url value='/js/jquery.min.js'/>"></script>
<script src="<c:url value='/js/jquery.cookie.js'/>"></script>
<script type="text/javascript">
	$(function() {
		var name= $.cookie('template_name');
		var des= $.cookie('template_des');
		var groupid= $.cookie('template_groupid');
		$("#template_name").val(name);
		$("#template_description").val(des);
		$(".selector").val(groupid);
	});
	function valid(){
		var name= $("#template_name").val();
		var des= $("#template_description").val();
		$.cookie('template_name', name);
		$.cookie('template_des', des);
		return true;
	}
</script>
<div class="page-header">
	<h3 style="margin-top: auto">
		检索架构模板
	</h3>
	<div class="form-inline">
		<div>
		<form class="form-search" action="<%=request.getContextPath()%>/aadl/template"
			method="POST" onsubmit="return valid();">
			<label class="control-label">项目类别</label>
					<select style="width: 200px" id="groupid" name="groupid" class="selector">
						<option value="0"></option>
						<c:choose>
							<c:when test="${!empty groups}">
								<c:forEach items="${groups}" var="list" varStatus="s">
									<option value="${list.id}">${list.name}</option>
								</c:forEach>
							</c:when>
						</c:choose>
					</select>
			<label class="control-label">名称</label><input type="text"
				style="margin-left: 10px;" class="input-large" placeholder="模板名称"
				id="template_name"><label style="margin-left: 50px;">描述信息</label><input
				type="text" style="margin-left: 10px;" class="input-xlarge"
				placeholder="模板描述信息" id="template_description">
				<button type="submit" style="margin-left: 10px;width: 100px" class="btn"
				id="btn_add_div"><i class="icon-search"></i>&nbsp;开始检索</button>
		</form>
		</div>
		<div style="margin-top: 10px;">
			
		</div>
	</div>
</div>
<div class="row-fluid">
	<div>
		<c:choose>
			<c:when test="${!empty bean and bean.allRow>0}">
				<table class="table table-hover">
					<thead>
						<tr>
							<th width="10%">编号</th>
							<th width="30%">名称</th>
							<th width="30%">所属项目类别</th>
							<th width="30%">操作
							<div style="float: right;">
									<button class="btn btn-small"
										onclick="window.location.href='<%=request.getContextPath()%>/aadl/template/edit';"><i class="icon-plus"></i>&nbsp;定义架构模板</button>
								</div>
							</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${bean.getList()}" var="list" varStatus="s">
							<tr>
								<td><c:out value="${s.count}" /></td>
								<td><c:out value="${list.name}" /></td>
								<td><c:if test="${!empty list.group}"><c:out value="${list.group.name}" /></c:if></td>
								<td>
								<div class='btn-group'>
								<c:set var="muri" value="${fn:replace(list.uri,':', '/')}" />
								<button class="btn" onclick="window.location.href='<%=request.getContextPath()%>/${muri}';"><i class="icon-search"></i>&nbsp;查看</button>
								<c:if test="${!empty list.model.owner and list.model.owner.id == id}"><button class="btn" onclick="window.location.href='<%=request.getContextPath()%>/${muri}/update';"><i class="icon-edit"></i>&nbsp;编辑</button></c:if>
								<button class="btn" onclick="window.location.href='<%=request.getContextPath()%>/${muri}/inherit';"><i class="icon-wrench"></i>&nbsp;复用</button>
								<c:if test="${!empty list.model.owner and list.model.owner.id == id}"><button class="btn" onclick="window.location.href='<%=request.getContextPath()%>/${muri}/delete';"><i class="icon-trash"></i>&nbsp;删除</button></c:if>
								</div></td>
							</tr>
						</c:forEach>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="8">
								<div class="pagination pagination-centered">
									<c:set value="${bean.getCurrentPage()}" var="currentPNum"
										scope="page"></c:set>
									<c:set value="${bean.getTotalPage()}" var="totalSize"
										scope="page"></c:set>
									<ul>
										<c:choose>
											<c:when test="${currentPNum == 1}">
												<li class="disabled"><a href="javascript:void(0);">&laquo;</a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/aadl/template?pageNum=${currentPNum-1}">&laquo;</a></li>
											</c:otherwise>
										</c:choose>
										<li class="active"><a href="javascript:void(0);"><c:out
													value="${currentPNum}" /></a></li>
										<c:choose>
											<c:when test="${currentPNum+1 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+1}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/aadl/template?pageNum=${currentPNum+1}"><c:out
															value="${currentPNum+1}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+2 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+2}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/aadl/template?pageNum=${currentPNum+2}"><c:out
															value="${currentPNum+2}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+3 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+3}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/aadl/template?pageNum=${currentPNum+3}"><c:out
															value="${currentPNum+3}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+4 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+4}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/aadl/template?pageNum=${currentPNum+4}"><c:out
															value="${currentPNum+4}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+1 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);">&raquo;</a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/aadl/template?pageNum=${currentPNum+1}">&raquo;</a></li>
											</c:otherwise>
										</c:choose>
									</ul>
								</div>
							<td>
					</tfoot>
				</table>
			</c:when>
			<c:otherwise>
				<h3 style="margin-top: auto">数据库暂无相关架构模板</h3>
			</c:otherwise>
		</c:choose>
	</div>
</div>
<!--/span-->